package beautify

import "gitee.com/hongzhaomin/hzm-common-go/strutil/color"

// TabFormatterType 表格格式化配置名称
type TabFormatterType string

const (
	Gird         TabFormatterType = "grid"         // 网格
	SnowFlake    TabFormatterType = "snowFlake"    // 雪花
	GirdSnow     TabFormatterType = "gridSnow"     // 雪花网格
	Colorful     TabFormatterType = "colorful"     // 炫彩
	RedTitleSnow TabFormatterType = "redTitleSnow" // 红色表头雪花
	GlobalYellow TabFormatterType = "globalYellow" // 全黄表格

	// 表头tag
	titleTag = "title"
)

var name2TabFormatterMap = map[TabFormatterType]TabFormatter{
	// [Vertex] 和 [DataSegment] 配置的字符长度，最好保持一致，否则可能影响表格美观
	Gird: {
		LeftMargin:        1,
		Padding:           1,
		Vertex:            "+",
		TitleTopBorder:    '-',
		TitleBottomBorder: '=',
		DataBorder:        '-',
		DataSegment:       "|",
		GlobalColor:       color.Empty,
	},
	SnowFlake: {
		LeftMargin:        1,
		Padding:           1,
		Vertex:            "*",
		TitleTopBorder:    '-',
		TitleBottomBorder: '=',
		DataBorder:        '-',
		DataSegment:       "|",
	},
	GirdSnow: {
		LeftMargin:        1,
		Padding:           1,
		Vertex:            "+",
		TitleTopBorder:    '-',
		TitleBottomBorder: '*',
		DataBorder:        '-',
		DataSegment:       "|",
	},
	Colorful: {
		LeftMargin:        1,
		Padding:           1,
		Vertex:            "",
		TitleTopBorder:    0, // 空字符
		TitleBottomBorder: 0, // 空字符
		DataBorder:        0, // 空字符
		DataSegment:       "|",
		GlobalColor:       color.Empty,
		TitleColorFun: func(_ string) color.Color {
			return color.RedBackground
		},
		CellColorFun: func(_, _ string) color.Color {
			return color.CyanBackground
		},
	},
	RedTitleSnow: {
		LeftMargin:        1,
		Padding:           1,
		Vertex:            "*",
		TitleTopBorder:    '-',
		TitleBottomBorder: '=',
		DataBorder:        '-',
		DataSegment:       "|",
		GlobalColor:       color.Empty,
		TitleColorFun: func(_ string) color.Color {
			return color.RedTextHighlight
		},
	},
	GlobalYellow: {
		LeftMargin:        1,
		Padding:           1,
		Vertex:            "*",
		TitleTopBorder:    '-',
		TitleBottomBorder: '=',
		DataBorder:        '-',
		DataSegment:       "|",
		GlobalColor:       color.YellowTextHighlight,
	},
}
